<?php
namespace app\home\controller;
use think\Controller;

class Shop extends Controller
{

	// 餐厅列表
    public function lists()
    {
        return $this->fetch();
    }
    

    // 餐厅详情
     public function detail()
    {
        //得到店铺信息
        $id=5;

        $shopinfo= \think\Db::name('dining')->where("shop_id='$id'")->select();
        //得到评论列表
        $list=\think\Db::view('message','id,uid,did,mdate as messdate,message')
        ->view('reply','id,mid,mdate as rdate,message,uid,shopid','message.id=reply.mid')
        ->view('users','pic as upic,nickname','message.uid=users.id')
        ->view('dining','pic as dpic,shop_id,shopname',"dining.shop_id='$id'")
        ->where("message.did='$id'")
        ->order("message.mdate desc")
        ->select();
        //得到美食类别和类别下的美食
        $type=\think\Db::name('type')->where("shop_id='$id'")->select();
        for( $i=0;$i<count($type);$i++)
        {
             $t=$type[$i]['type_id'];
            $foodList=\think\Db::name('food')->where("shop_id='$id' AND type_id='$t'")->select();
            /*var_dump($foodList);
            echo "<hr/>";
            echo "<br/>";*/
        }
        
        $this->assign("list",$list);
        $this->assign("shopinfo",$shopinfo);
        return $this->fetch();
    }


     //热门（人气）餐厅列表（按订单数降序排列）
     public function hotshoplists()
    {
//      $hotshoplist =\think\Db::name('room')->alias('a')->join('dining b','a.id=b.did')->count('id desc')->select();
//      $this->assign('hotshoplist',$hotshoplist);
        return $this->fetch();
    }


     // 新进餐厅列表（按时间降序排列）
     public function newshoplists()
     {
         $newshop = \think\Db::name('dining')->order('createtime desc')->select();
         $this->assign('newsshops',$newshop);
        return $this->fetch();
    }

    public  function  order(){
       $user = session('id');//获取用户ID
      if (request()->isPost()){


      }


    }



}
